package com.cgi.ndk.wf.pack;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author brizat
 */
@RestController
@RequestMapping("/packages")
public class PackageController {

    @Autowired
    PackageService packageService;

    @RequestMapping(method = RequestMethod.POST)
    public ResponseEntity<Package> save(@RequestBody Package pack) {
        return packageService.save(pack);
    }

    @RequestMapping
    public ResponseEntity<List<Package>> packages() {
        return packageService.packages();
    }

    @RequestMapping("/{id}")
    public ResponseEntity<Package> getPackage(@PathVariable("id") String id) {
        return packageService.getPackage(id);
    }
}
